package com.guoxin.jiyin.model;

import com.guoxin.jiyin.enums.ICommonEnum;
import lombok.Data;

@Data
public class ApiResult<T> {
    /**
     * 系统状态返回：1，成功;0，失败
     */
    private Integer code = 1;
    /**
     * 成功/失败描述
     */
    private String message;

    /**
     * 返回具体数据
     */
    private Object data;


    public static <T extends ICommonEnum> ApiResult resultWith(T code, Object data) {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(code.getValue());
        apiResult.setMessage(code.getName());
        apiResult.setData(data);
        return apiResult;
    }

    public static <T extends ICommonEnum> ApiResult resultWith(T code) {
        return resultWith(code, "");
    }

}
